@extends('admin.admin')

@section('content')
<?php

Form::macro(
        'selectRequired',
        function($name, $options = [], $selected = null, $attributes = [], $disabled = [])
        {
            $html = '<select name="' . $name . '"';
            foreach ($attributes as $attribute => $value)
            {
                $html .= ' ' . $attribute . '="' . $value . '"';
            }
            $html .= '>';

            foreach ($options as $value => $text)
            {
                $html .= '<option value="' . $value . '"' .
                        ($value == $selected ? ' selected="selected"' : '') .
                        (in_array($value, $disabled) ? ' disabled="disabled"' : '') . '>' .
                        $text . '</option>';
            }

            $html .= '</select>';

            return $html;
        }
);?>
        <!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        商品管理
        <small>商品列表</small>
        <small>添加</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 控制面板</a></li>
        <li >商品管理</li>
        <li ><a href="/admin/goods">商品列表</a></li>
        <li class="active">添加</li>
    </ol>
</section>
<!-- Main content -->
<section class="content">

    <div class="row">
        <div class="col-xs-12">
            <div class="box box-primary">
                {!! Form::model($goods,['route'=>'admin.goods.store','method' => 'post','class'=>'form-horizontal']) !!}


                <div class="box-header with-border">
                    <h3 class="box-title">商品添加</h3>
                    <div class="box-tools">
                        <a href="{{Route('admin.goods.index')}}" type="button" class="btn btn-block btn-success btn-xs"><i class="icon  glyphicon glyphicon glyphicon-menu-left"></i> 返回</a>
                    </div>
                </div>

                <div class="box-body ">

                    <div class="nav-tabs-custom">
                        <ul class="nav nav-tabs" id="nav">
                            <li class="active"><a href="#base" data-toggle="tab">基本信息</a></li>
                            <li><a href="#gallery" data-toggle="tab">商品相册</a></li>
                            <li><a href="#detail" data-toggle="tab">详情描述</a></li>
                            <li><a href="#mobile_detail" data-toggle="tab">手机端详情描述</a></li>
                        </ul>

                        <div class="tab-content">

                            <div class="active tab-pane" id="base">

                                <?php $select = $category::getTreeList();?>

                                <?php

                                function myspace($n,$hasChild){
                                    $enum = ['├','└'];
                                    if ($hasChild){
                                        $space = $enum[0];
                                    }else{
                                        $space = $enum[1];
                                    }
                                    $str = '';
                                    for ($i=0;$i<=$n;$i++){
                                        $str.='&nbsp;&nbsp;';
                                    }
                                    return $str.$space;
                                }
                                $seletcItem[0] = '=请选择商品分类=';
                                $disabledOption = [];
                                foreach ($select as $k=> $item){
                                    if($item->has_children){
                                        $disabledOption[]=$item->cat_id;
                                    }
                                    $seletcItem [$item->cat_id]= myspace($item->deepth,$item->has_children).$item->cat_name;
                                }

                                ?>
                                <div class="form-group @if($errors->has('cat_id')) has-error   @endif">
                                    <label class="col-sm-2 control-label" for="exampleInputPassword1">商品分类</label>
                                    <div class="col-sm-3">
                                        {!! Form::selectRequired('cat_id',$seletcItem,old('cat_id'),['class'=>'form-control select2','id'=>'cat_id'],$disabledOption)!!}
                                        @if($errors->has('cat_id'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('cat_id')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('goods_name')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品名称</label>
                                    <div class="col-sm-3">
                                        {!! Form::text('goods_name',old('goods_name'),array('class'=>'form-control','placeholder'=>'商品名称'))!!}

                                        @if($errors->has('goods_name'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_name')}}</label>
                                        @endif
                                    </div>
                                </div>
                                <div class="form-group @if($errors->has('goods_sn')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品编码</label>
                                    <div class="col-sm-3">
                                        {!! Form::text('goods_sn',old('goods_sn'),array('class'=>'form-control','placeholder'=>'商品编码'))!!}

                                        @if($errors->has('goods_sn'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_sn')}}</label>
                                        @elseif(Session::has('message'))
                                            <label class="control-label" style="color: red" for="inputError"><i class="fa fa-times-circle-o" style="color: red"></i> {{Session::get('message')}}</label>
                                        @endif
                                    </div>
                                </div>
                                <div class="form-group @if($errors->has('goods_bar_code')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品条形码</label>
                                    <div class="col-sm-3">
                                        {!! Form::text('goods_bar_code',old('goods_bar_code'),array('class'=>'form-control','placeholder'=>'商品条形码'))!!}

                                        @if($errors->has('goods_bar_code'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_bar_code')}}</label>
                                        @endif
                                    </div>
                                </div>
                                <div class="form-group @if($errors->has('goods_pet_name')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品副标题</label>
                                    <div class="col-sm-3">
                                        {!! Form::text('goods_pet_name',old('goods_pet_name'),array('class'=>'form-control','placeholder'=>'商品副标题'))!!}

                                        @if($errors->has('goods_pet_name'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_pet_name')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('goods_thumb')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品缩略图</label>

                                    <div class="col-sm-3">
                                        <div style="width: 170px;">
                                            <div class="box  box-default image-uploader">
                                                <style>
                                                    .upload-btn{
                                                        display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                    }
                                                </style>
                                                <!-- /.box-header -->
                                                <div class="box-body">

                                                    <div style="width: 145px;height: 145px; display: block;">
                                                        <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url')) {{old('image_url')}} @else http://placehold.it/800x800 @endif"/>
                                                        <input type="hidden" id="image_url" name="image_url" value="{{old('image_url')}}">
                                                    </div>
                                                    <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                    </div>

                                                    <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                        <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                        </div>
                                                    </div>
                                                </div>
                                                <!-- /.box-body -->
                                                <div class="box-footer" style="position: relative">

                                                    <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                    {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                    {!! Form::hidden('goods_thumb',old('goods_thumb'),['id'=>'thumb']) !!}

                                                    <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                </div>
                                            </div>
                                            <!-- /.box -->
                                        </div>

                                    </div>

                                    @if($errors->has('goods_thumb'))
                                        <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_thumb')}}</label>
                                    @endif
                                </div>

                                <div class="form-group @if($errors->has('goods_desc')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品简介</label>
                                    <div class="col-sm-3">
                                        {!! Form::textarea('goods_desc',old('goods_desc'),array('class'=>'form-control','placeholder'=>'请填写商品简介','rows'=>3))!!}
                                        
                                        @if($errors->has('goods_desc'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_desc')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('resource')) has-error   @endif">

                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品来源</label>
                                    <div class='col-sm-3'>
                                        {!! Form::text('resource',old('resource'),array('class'=>'form-control','placeholder'=>'商品来源', 'id'=>'resource' ))!!}

                                        @if($errors->has('resource'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('resource')}}</label>
                                        @endif
                                    </div>
                                </div>


                                <div class="form-group @if($errors->has('shop_id')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">店铺</label>
                                    <div class="col-sm-3">
                                        {!! Form::select('shop_id',$shopArr,old('shop_id'),['class'=>'form-control', 'id'=>'shop_id' ])!!}

                                        @if($errors->has('shop_id'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('shop_id')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('brand_id')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">品牌</label>
                                    <div class="col-sm-3">
                                        {!! Form::select('brand_id',$brandArr,old('brand_id'),['class'=>'form-control select2', 'id'=>'brand_id' ])!!}

                                        @if($errors->has('brand_id'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('brand_id')}}</label>
                                        @endif
                                    </div>
                                </div>



                                <div class="form-group @if($errors->has('goods_number')) has-error   @endif">
                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品库存</label>
                                    <div class='col-sm-3'>
                                        {!! Form::text('goods_number',old('goods_number'),array('class'=>'form-control','placeholder'=>'商品库存'))!!}
                                    
                                        @if($errors->has('goods_number'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_number')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div style="display: none;" class="form-group @if($errors->has('goods_weight')) has-error   @endif">

                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商品重量(kg)</label>
                                    <div class='col-sm-3'>
                                        {!! Form::text('goods_weight',old('goods_weight'),array('class'=>'form-control','placeholder'=>'商品重量'))!!}
                                    
                                        @if($errors->has('goods_weight'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_weight')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('market_price')) has-error   @endif">

                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">国内参考价</label>
                                    <div class='col-sm-3'>

                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            {!! Form::text('market_price',old('market_price'),array('class'=>'form-control','placeholder'=>'国内参考价'))!!}
        
                                            <!-- <span class="input-group-addon">.00</span> -->
                                        </div>
                                        @if($errors->has('market_price'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('market_price')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('shop_price')) has-error   @endif">

                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">商城价格</label>
                                    <div class='col-sm-3'>
                                        <div class="input-group">
                                            <span class="input-group-addon">￥</span>
                                            {!! Form::text('shop_price',old('shop_price'),array('class'=>'form-control','placeholder'=>'商城价格'))!!}
                                            
                                            <!-- <span class="input-group-addon">.00</span> -->
                                        </div>
                                        @if($errors->has('shop_price'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('shop_price')}}</label>
                                        @endif
                                    </div>
                                </div>

                                <div class="form-group @if($errors->has('keywords')) has-error   @endif">

                                    <label for="exampleInputPassword1" class="col-sm-2 control-label">搜索关键词</label>
                                    <div class='col-sm-3'>
                                        {!! Form::text('keywords',old('keywords'),array('class'=>'form-control','placeholder'=>'关键词之间使用","隔开'))!!}
                                        
                                        @if($errors->has('keywords'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('keywords')}}</label>
                                        @endif
                                    </div>
                                </div>

                                    <div class="form-group @if($errors->has('type')) has-error   @endif">
                                        <label for="exampleInputPassword1" class="col-sm-2 control-label">类别</label>
                                        <div class="col-sm-3">
                                            {!! Form::select('type',$typeArr,old('type'),['class'=>'form-control', 'id'=>'type' ])!!}

                                            @if($errors->has('type'))
                                                <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('type')}}</label>
                                            @endif
                                        </div>
                                    </div>



                                    <div class="form-group">
                                        <label for="weight" class="col-sm-2 control-label"></label>

                                        <div class="col-sm-3">
                                            <button onclick="javascript:$('#nav li:eq(1) a').tab('show');" data-toggle="tab"  aria-expanded="true" class="btn btn-primary">下一步</button>
                                        </div>
                                    </div>

                            </div>
                            <!-- /.tab-pane -->
                            <div class="tab-pane row" id="gallery">

                                <div class="row" style="padding-left:30px;">
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group">

                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_1')) {{old('image_url_1')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_1" value="{{old('image_url_1')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_1]',old('goods_gallery[pic_1]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>

                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group ">
                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_2')) {{old('image_url_2')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_2" value="{{old('image_url_3')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_2]',old('goods_gallery[pic_2]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>

                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group ">
                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_3')) {{old('image_url_3')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_3" value="{{old('image_url_3')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_3]',old('goods_gallery[pic_3]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>

                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group ">

                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_4')) {{old('image_url_4')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_4" value="{{old('image_url_4')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_4]',old('goods_gallery[pic_4]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>

                                        </div>
                                    </div>
                                </div>
                                <div class="row" style="padding-left:30px;">
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group">

                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_5')) {{old('image_url_5')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_5" value="{{old('image_url_5')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_5]',old('goods_gallery[pic_5]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>

                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group ">

                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_6')) {{old('image_url_6')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_6" value="{{old('image_url_6')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_6]',old('goods_gallery[pic_6]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>


                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group ">

                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_7')) {{old('image_url_7')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_7" value="{{old('image_url_7')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_7]',old('goods_gallery[pic_7]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>

                                        </div>
                                    </div>
                                    <div class="col-lg-3 col-xs-6">
                                        <div class="form-group ">
                                            <div style="width: 170px;">
                                                <div class="box  box-default image-uploader">
                                                    <style>
                                                        .upload-btn{
                                                            display: block; width:48px;height:30px;position: absolute;filter:alpha(opacity=0);-moz-opacity:0;-khtml-opacity: 0;opacity: 0;
                                                        }
                                                    </style>
                                                    <!-- /.box-header -->
                                                    <div class="box-body">

                                                        <div style="width: 145px;height: 145px; display: block;">
                                                            <img class="image" style="width: 145px;; padding: 1px;" width="145" height="145" src="@if (old('image_url_8')) {{old('image_url_8')}} @else http://placehold.it/800x800 @endif"/>
                                                            <input type="hidden" id="image_url" name="image_url_8" value="{{old('image_url_8')}}">
                                                        </div>
                                                        <div class="message" style="width: 145px;height: 145px; display: block;position: absolute; padding: 5px; top:0px; color: red; text-align: center; line-height: 145px;display: none;">

                                                        </div>

                                                        <div class="progress progress-xxs" style="position: absolute;width: 140px; left:13px; display: none;">
                                                            <div class="progress-bar progress-bar-default " role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <!-- /.box-body -->
                                                    <div class="box-footer" style="position: relative">

                                                        <button class="btn btn-sm btn-default btn-flat pull-left" type="button">上传</button>
                                                        {!! Form::file('file',['class'=>'upload-btn','id'=>'fileupload','type'=>'file','data-url'=>'/admin/file_upload']) !!}
                                                        {!! Form::text('goods_gallery[pic_8]',old('goods_gallery[pic_8]'),['style'=>'display:none;','id'=>'thumb']) !!}

                                                        <button class="btn  btn-sm btn-danger btn-flat pull-right" type="button">删除</button>
                                                    </div>
                                                </div>
                                                <!-- /.box -->
                                            </div>


                                        </div>
                                    </div>
                                </div>

                                <div class="form-group ">
                                    <label for="weight" class="col-sm-2 control-label"></label>

                                    <div class="col-sm-3">
                                        <button type="button" onclick="javascript:$('#nav li:eq(0) a').tab('show');"   class="btn btn-primary">上一步</button>
                                        <button type="button" onclick="javascript:$('#nav li:eq(2) a').tab('show');"  class="btn btn-primary">下一步</button>

                                    </div>
                                </div>

                            </div>
                            <!-- /.tab-pane -->

                            <div class="tab-pane" id="detail">


                                <div class="form-group ">
                                    <div class="col-sm-12">
                                        {!! Form::textarea('goods_content', @$goodsInfo->goods_content, array('class'=>'form-control','placeholder'=>'', 'id'=>'editor', 'autofocus'))!!}
                                        @if($errors->has('goods_content'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('goods_content')}}</label>
                                        @endif
                                    </div>
                                </div>



                                <div class="form-group ">
                                    <label for="weight" class="col-sm-2 control-label"></label>

                                    <div class="col-sm-3">
                                        <button type="button"  onclick="javascript:$('#nav li:eq(1) a').tab('show');" class="btn btn-primary">上一步</button>
                                        <button type="button" onclick="javascript:$('#nav li:eq(3) a').tab('show');"  class="btn btn-primary">下一步</button>
                                        <!-- <button type="submit"  class="btn btn-primary">保存</button> -->

                                        {{--{!! Form::checkbox('is_audit',0) !!}审核通过--}}

                                        {{--{!! Form::checkbox('is_on_sale',0) !!}上架--}}
                                </div>
                                </div>

                            </div>
                            <!-- /.tab-pane -->

                            <div class="tab-pane" id="mobile_detail">


                                <div class="form-group ">
                                    <div class="col-sm-12">
                                        {!! Form::textarea('mobile_goods_content', @$goodsInfo->mobile_goods_content, array('class'=>'form-control','placeholder'=>'', 'id'=>'mobile_editor', 'autofocus'))!!}
                                        @if($errors->has('mobile_goods_content'))
                                            <label class="control-label" for="inputError"><i class="fa fa-times-circle-o"></i> {{$errors->first('mobile_goods_content')}}</label>
                                        @endif
                                    </div>
                                </div>



                                <div class="form-group ">
                                    <label for="weight" class="col-sm-2 control-label"></label>

                                    <div class="col-sm-3">
                                        <button type="button"  onclick="javascript:$('#nav li:eq(2) a').tab('show');" class="btn btn-primary">上一步</button>
                                        <button type="submit"  class="btn btn-primary">保存</button>

                                        {{--{!! Form::checkbox('is_audit',0) !!}审核通过--}}

                                        {{--{!! Form::checkbox('is_on_sale',0) !!}上架--}}
                                </div>
                                </div>

                            </div>
                            <!-- /.tab-pane -->

                        </div>
                        <!-- /.tab-content -->
                    </div>

                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    {!! Form::hidden('_method', 'POST') !!}


                </div>
                {!! Form::close() !!}

            </div>
            <!-- /.box -->
        </div>
    </div>



</section>
<!-- /.content -->


<script type="text/javascript">
    $(function(){
        toolbar = [ 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
            'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|',
            'link', 'image', 'hr', '|', 'indent', 'outdent' ];
        var editor = new Simditor( {
            textarea : $('#editor'),
            placeholder : '请编辑商品描述（图片宽度为848）...',
            toolbar : toolbar,  //工具栏
            upload : {
                url : '/admin/file_upload', //文件上传的接口地址
                params: {'X-CSRF-TOKEN':'{{csrf_token()}}'}, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                fileKey: 'file', //服务器端获取文件数据的参数名
                connectionCount: 3,
                leaveConfirm: '正在上传文件'
            }
        });
    })
    $(function(){
        toolbar = [ 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
            'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|',
            'link', 'image', 'hr', '|', 'indent', 'outdent' ];
        var editor = new Simditor( {
            textarea : $('#mobile_editor'),
            placeholder : '请编辑手机端商品描述...',
            toolbar : toolbar,  //工具栏
            upload : {
                url : '/admin/file_upload', //文件上传的接口地址
                params: {'X-CSRF-TOKEN':'{{csrf_token()}}'}, //键值对,指定文件上传接口的额外参数,上传的时候随文件一起提交
                fileKey: 'file', //服务器端获取文件数据的参数名
                connectionCount: 3,
                leaveConfirm: '正在上传文件'
            }
        });
    })
</script>
<script src="{{ asset ("/components/blueimp-file-upload/js/vendor/jquery.ui.widget.js") }}"></script>
<script src="{{ asset ("/components/blueimp-file-upload/js/jquery.iframe-transport.js") }}"></script>
<script src="{{ asset ("/components/blueimp-file-upload/js/jquery.fileupload.js") }}"></script>
<!-- Select2 -->
<script type="text/javascript" src="{{ asset("/components/AdminLTE/plugins/select2/select2.full.min.js") }}"></script>

<script>
    //Initialize Select2 Elements
    $(".select2").select2();

    $(function () {
        $('.image-uploader').each(function(k,imageUploader){
            var wrapper = $(imageUploader);//盒子
            var uploadBtn = wrapper.find('#fileupload');
            var imageFile = wrapper.find('.image');
            var progress = wrapper.find('.progress');
            var progressBar = progress.find('.progress-bar');
            var inputFile = wrapper.find('#thumb');
            var imageUrl = wrapper.find('#image_url');
            var message = wrapper.find('.message');

            uploadBtn.click(function(){
                progressBar.css('width', 0 + '%');
                imageFile.attr('src','http://placehold.it/800x800');
                inputFile.val('');
                message.hide();

            });
            wrapper.find('.btn-danger').click(function(){
                progressBar.css('width', 0 + '%');
                imageFile.attr('src','http://placehold.it/800x800');
                inputFile.val('');
                message.hide();

            });

            uploadBtn.fileupload({
                dataType: 'json',
                headers:{'X-CSRF-TOKEN':'{{csrf_token()}}'},
                add: function (e, data) {
                    data.submit();
                },
                progressall: function (e, data) {
                    progress.fadeIn();
                    var percent = parseInt(data.loaded / data.total * 100, 10);
                    if (progress==1){
                        progress.show()
                    }
                    progressBar.css('width', percent + '%');
                    setTimeout(function () {
                        progress.fadeOut();
                    }, 500);
                },
                done: function (e, data) {
                    imageFile.attr('src',data.result.url);
                    inputFile.val(data.result.id);
                    imageUrl.val(data.result.url);
                },
                complete:function(){
                }
            });
        });
    });




    function load_brand(){
        var cat_id = $('#cat_id').val();

        var brandSel=$("#brand_id");
        brandSel.empty();

        if(cat_id==0 || cat_id=='' || cat_id==null){
            alert('请先选择商品分类');
            brandSel.append('<option value="0">=请选择品牌=</option>');
        }else{
            urls = "/admin/categoryBrand/"+cat_id;

            $.ajax({
                type: "GET",
                url: urls,
                data: '',
                dataType: "json",
                headers: {
                    'X-CSRF-Token': "{{csrf_token()}}"
                },
                async:true,
                cache:false,
                success: function (msg) {

                    brandSel.append('<option value="0">=请选择品牌=</option>');
                    $.each(msg, function(n, value){
                        brandSel.append('<option value="'+n+'">'+value+'</option>');
                    });
                    if(msg=='' || msg==null){
                        brandSel.append('<option value="0">=该商品分类下无品牌可选=</option>');

                    }//end if()
                    brandSel.select2();
                }
            }); //end ajax

        }//end if()
    }


    <!-- 根据分类显示分类下的品牌 -->
    $('#cat_id').change(function(){

        load_brand();

    });

    $("#type").change(function(e){

        var obj = $(e.currentTarget);

        if (obj.val()=='0'){
            $('#etrade').hide();

        }else{
            $('#etrade').show();
        }

    });


</script>

@if ($errors->count()>0)
<script>
    load_brand();

</script>
@endif;


@endsection